package tw.com.book.task01;

import tw.com.book.R;
import tw.com.book.api.task01.MainTaskService;
import tw.com.book.componet.DBContract;
import tw.com.book.core.task01.MainTaskServiceImpl;
import tw.com.book.domain.V002Type;
import tw.com.book.dto.MainDTO;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

/**
 * 修改內容＋增加修改狀態
 * @author Andy
 *
 */
public class PendContentActivity extends Activity {

	private Button saveBtn;
	private EditText content;
	private MainDTO dto = new MainDTO();
	private MainTaskService mainTaskService = new MainTaskServiceImpl();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.issue_edit_view);

		final Bundle bundle = this.getIntent().getExtras();

		final V002Type v002 = (V002Type) bundle
				.getSerializable(DBContract.V002_TABLE);

		this.dto.setSelectV002(v002);

		this.saveBtn = (Button) this.findViewById(R.id.saveBtn);

		this.content = (EditText) this.findViewById(R.id.content);

		
		
		this.saveBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				dto.setNewContent(content.getText().toString());
				mainTaskService.pendContent(dto, PendContentActivity.this);
				finish();
				// TODO Auto-generated method stub

			}
		});

		
		this.content.setText(dto.getSelectV002().getContent());
	}

}
